<?php

namespace App\models\forum;

use App\models\user\User;
use Illuminate\Database\Eloquent\Model;

/**
 * App\models\forum\Topic
 *
 * @property int $id
 * @property string $title
 * @property string $body
 * @property int $uid
 * @property int $category_id
 * @property int $pid
 * @property bool $is_reply
 * @property int $stand_count
 * @property int $against_count
 * @property int $reply_count
 * @property int $click_count
 * @property int $read_flag
 * @property string $deleted_at
 * @property \Carbon\Carbon $created_at
 * @property \Carbon\Carbon $updated_at
 * @property-read \App\models\user\User $user
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\models\forum\Replie[] $replie
 * @property-read \App\models\forum\Categorie $categorie
 * @property-read \App\models\forum\Partition $partition
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Topic whereId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Topic whereTitle($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Topic whereBody($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Topic whereUid($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Topic whereCategoryId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Topic wherePid($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Topic whereIsReply($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Topic whereStandCount($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Topic whereAgainstCount($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Topic whereReplyCount($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Topic whereClickCount($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Topic whereReadFlag($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Topic whereDeletedAt($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Topic whereCreatedAt($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Topic whereUpdatedAt($value)
 * @mixin \Eloquent
 * @property int $chang_user_id
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Topic whereChangUserId($value)
 * @property string $body_original
 * @property bool $is_delete
 * @property-read \App\models\user\User $changUser
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\models\forum\TopicVote[] $vote
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Topic whereBodyOriginal($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\Topic whereIsDelete($value)
 */
class Topic extends Model
{
    public function user(){
        return $this->belongsTo(User::class, 'uid', 'id');
    }

    public function replie(){
        return $this->hasMany(Replie::class, 'topic_id', 'id');
    }

    public function categorie(){
        return $this->belongsTo(Categorie::class, 'category_id', 'id');
    }

    public function partition(){
        return $this->belongsTo(Partition::class, 'pid', 'id');
    }

    public function changUser(){
        return $this->belongsTo(User::class, 'chang_user_id', 'id');
    }

    public function vote(){
        return $this->hasMany(TopicVote::class, 'topic_id', 'id');
    }
}
